package cn.xbtop.blog.service.impl;

import cn.xbtop.blog.mapper.LogMapper;
import cn.xbtop.blog.pojo.Log;
import cn.xbtop.blog.service.LogService;
import cn.xbtop.blog.utils.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/2/19 15:48
 */
@Service
public class LogServiceImpl implements LogService {

    @Resource
    private LogMapper logMapper;

    @Override
    public int deleteByPrimaryKey(Integer logId) {
        return logMapper.deleteByPrimaryKey(logId);
    }

    @Override
    public int insert(Log log) {
        return logMapper.insert(log);
    }
    

    /**
     * 分页查询所有
     *
     * @param pageBean
     * @return
     */
    @Override
    public PageBean<Log> findByPage(PageBean<Log> pageBean) {
        //查询数据
        List<Log> logList = logMapper.findByPage(pageBean);
        pageBean.setList(logList);
        //查询总数
        int totalCount = logMapper.findTotal();
        pageBean.setTotalCount(totalCount);

        //返回pageBean对象
        return pageBean;
    }

    /**
     * 批量删除
     *
     * @param ids
     */
    @Override
    public void deleteByIds(List<Integer> ids) {
        //暂未实现
        //for (Integer i : ids) {
        //    deleteByPrimaryKey(i);
        //}
        logMapper.deleteByIds(ids);
    }
}
